// npm install mysql 安装mysql
const mysql = require('mysql') // 引入mysql
// 创建一个数据库连接对象
const connection = mysql.createConnection({
    host:'localhost',
    user:'root',
    password:'b123',
    database:'goodsmanager_db'
})

// 创建连接
connection.connect()

// 执行SQL语句
// const sql = 'INSERT INTO users(username,password,age,sex) VALUES ("root","123",18,"女")'
// const sql = 'UPDATE users SET password = "abcd" WHERE username = "root"'
// const sql = 'SELECT id,username,password,age,sex FROM users WHERE id=2'
 const sql = 'DELETE FROM users WHERE username="root" AND password = "abcd"'
connection.query(sql, function(err,results){
    if(err){
        console.log('操作数据库出错 ',err);
        return
    }
    console.log(results);
    
})

connection.end() // 结束连接